﻿using DotNetLib.Windows.Forms;


namespace ExtensibleEventViewer.Console.Adapters
{
	internal abstract class AdapterBase<T>
	{
		private ContainerListViewItem _listViewItem;
		private readonly T _dataItem;

		protected AdapterBase(T dataItem)
		{
			_dataItem = dataItem;
		}

		protected abstract ContainerListViewItem CreateListViewItem(T dataItem);

		public ContainerListViewItem ListViewItem
		{
			get
			{
				if (_listViewItem == null)
				{
					_listViewItem = CreateListViewItem(_dataItem);

					_listViewItem.Tag = this;
				}

				return _listViewItem;
			}
		}

		public T DataItem
		{
			get { return _dataItem; }
		}
	}
}
